<?php

namespace backend\controllers;

use backend\models\SearchPart;
use Yii;
use backend\models\JobType;
use backend\actions\CreateAction;
use backend\actions\UpdateAction;
use backend\actions\IndexAction;
use backend\actions\DeleteAction;
use backend\actions\SortAction;
use backend\actions\ViewAction;
use yii\data\ActiveDataProvider;

/**
 * SearchPartController implements the CRUD actions for JobType model.
 */
class SearchPartController extends \yii\web\Controller
{
    public function actions()
    {
        return [
            'index'      => [
                'class' => IndexAction::className(),
                'data'  => function () {

                    $dataProvider = new ActiveDataProvider([
                        'query' => SearchPart::find()->where([
                            'in',
                            'type',
                            [SearchPart::TYPE_TIME, SearchPart::TYPE_SALARY, SearchPart::TYPE_LOCATION]
                        ]),
                    ]);

                    return [
                        'dataProvider' => $dataProvider,
                    ];

                }
            ],
            'create'     => [
                'class'      => CreateAction::className(),
                'modelClass' => SearchPart::className(),
            ],
            'update'     => [
                'class'      => UpdateAction::className(),
                'modelClass' => SearchPart::className(),
            ],
            'delete'     => [
                'class'      => DeleteAction::className(),
                'modelClass' => SearchPart::className(),
            ],
            'sort'       => [
                'class'      => SortAction::className(),
                'modelClass' => SearchPart::className(),
            ],
            'view-layer' => [
                'class'      => ViewAction::className(),
                'modelClass' => SearchPart::className(),
            ],
        ];
    }
}
